<?php
/**
 * Created by PhpStorm.
 * User: 35083
 * Date: 2019/7/5
 * Time: 10:34
 */

namespace app\admin\mapper;


class Common
{
    static private $instance = null;

    static public function getInstance()
    {
        //判断$instance是否是Uni的对象
        //没有则创建
        if (self::$instance == null) {
            self::$instance = new self();
        }
        return self::$instance;

    }
    public function statsMapper($ty)
    {
        $string = "";
        if ($ty == '0') {
            $string = "<font>上架</font>";
        } else if ($ty == '1') {
            $string = "<font>下架</font>";
        }
        return $string;
    }

    public function hotMapper($ty)
    {
        $string = "";
        if ($ty == '0') {
            $string = "<font>普通</font>";
        } else if ($ty == '1') {
            $string = "<font>推荐</font>";
        }
        return $string;
    }

    public function listMapper($list)
    {
        foreach ($list as $key => $val) {
            $list[$key] = $this->infoMapper($val);
        }
        return $list;
    }

    public function infoMapper($info)
    {
        $info['hotMapper'] = $this->hotMapper($info['hot']);
        $info['statsMapper'] = $this->statsMapper($info['stats']);
        $info['ctimeMapper'] = formateDate($info['ctime']);
        return $info;
    }
}